package com.exam.controller;

import com.exam.pojo.entity.ScoreStu;
import com.exam.service.impl.ScoreStuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


import java.util.List;

@Controller
public class ScoreStuController {
   @Autowired
   ScoreStuServiceImpl scoreStuService;
   /*
* 我的成绩
* */
   //所有我的成绩
    @RequestMapping( "score-student.html")
    public String scoreStuList(Model model) {
        List<ScoreStu> scoreList = scoreStuService.findAll();
        List<ScoreStu> allName = scoreStuService.findAllName();
        System.out.println(scoreList);
        model.addAttribute("scoreList", scoreList);
        model.addAttribute("allName", allName);
        return "score-student";
    }
    //条件查询
    @PostMapping("examName")
    public String   selectStion(Model model,String examName){
        System.out.println(examName);
        List<ScoreStu> scoreList = scoreStuService.findStuScore(examName);
        List<ScoreStu> allName = scoreStuService.findAllName();
        System.out.println(scoreList);
        model.addAttribute("scoreList",scoreList);
       model.addAttribute("allName", allName);
        return "score-student";
    }




}
